package com.yuanlrc.hotel.room.service.impl;

import java.util.List;

import com.yuanlrc.hotel.rommType.domain.RoomType;
import com.yuanlrc.hotel.rommType.mapper.RoomTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yuanlrc.hotel.room.mapper.RoomMapper;
import com.yuanlrc.hotel.room.domain.Room;
import com.yuanlrc.hotel.room.service.IRoomService;
import com.yuanlrc.common.core.text.Convert;

/**
 * 房间管理Service业务层处理
 * 
 * @author yuanlrc
 * @date 2020-11-19
 */
@Service
public class RoomServiceImpl implements IRoomService 
{
    @Autowired
    private RoomMapper roomMapper;

    @Autowired
    private RoomTypeMapper roomTypeMapper;

    /**
     * 查询房间管理
     * 
     * @param id 房间管理ID
     * @return 房间管理
     */
    @Override
    public Room selectRoomById(Integer id)
    {
        return roomMapper.selectRoomById(id);
    }

    /**
     * 查询房间管理列表
     * 
     * @param room 房间管理
     * @return 房间管理
     */
    @Override
    public List<Room> selectRoomList(Room room)
    {
        List<Room> rooms = roomMapper.selectRoomList(room);
        for (Room item: rooms) {
            item.setRoomType(roomTypeMapper.selectRoomTypeById(item.getRoomTypeId().longValue()));
        }
        return rooms;
    }

    /**
     * 新增房间管理
     * 
     * @param room 房间管理
     * @return 结果
     */
    @Override
    public int insertRoom(Room room)
    {
        return roomMapper.insertRoom(room);
    }

    /**
     * 修改房间管理
     * 
     * @param room 房间管理
     * @return 结果
     */
    @Override
    public int updateRoom(Room room)
    {
        return roomMapper.updateRoom(room);
    }

    /**
     * 删除房间管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteRoomByIds(String ids)
    {
        return roomMapper.deleteRoomByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除房间管理信息
     * 
     * @param id 房间管理ID
     * @return 结果
     */
    @Override
    public int deleteRoomById(Integer id)
    {
        return roomMapper.deleteRoomById(id);
    }

    @Override
    public List<Room> selectRoomListByRoomTypeId(Integer id) {
        return roomMapper.selectRoomListByRoomTypeId(id);
    }

    @Override
    public List<Room> selectRoomListByHourTimeAll() {
        return roomMapper.selectRoomListByHourTimeAll();
    }

    @Override
    public List<Room> selectRoomListByRoomTypeIdAndHourTime(Integer id) {
        return roomMapper.selectRoomListByRoomTypeIdAndHourTime(id);
    }

    @Override
    public List<Room> selectRoomListNormal() {
        return roomMapper.selectRoomListNormal();
    }

    @Override
    public Room selectRoomByRoomNumber(String roomNumber) {
        return roomMapper.selectRoomByRoomNumber(roomNumber);
    }

    @Override
    public List<Room> selectRoomListTop8() {
        return roomMapper.selectRoomListTop8();
    }

}
